home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / gutenprint / array.h next >
Encoding:
C/C++ Source or Header  |  2008-03-15  |  5.1 KB  |  170 lines

  1. /*
  2.  * "$Id: array.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
  3.  *
  4.  *   Copyright 2003 Roger Leigh (rleigh@debian.org)
  5.  *
  6.  *   This program is free software; you can redistribute it and/or modify it
  7.  *   under the terms of the GNU General Public License as published by the Free
  8.  *   Software Foundation; either version 2 of the License, or (at your option)
  9.  *   any later version.
  10.  *
  11.  *   This program is distributed in the hope that it will be useful, but
  12.  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13.  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14.  *   for more details.
  15.  *
  16.  *   You should have received a copy of the GNU General Public License
  17.  *   along with this program; if not, write to the Free Software
  18.  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. /**
  22.  * @file gutenprint/array.h
  23.  * @brief Array functions.
  24.  */
  25.  
  26. /*
  27.  * This file must include only standard C header files.  The core code must
  28.  * compile on generic platforms that don't support glib, gimp, gimpprint, etc.
  29.  */
  30.  
  31. #ifndef GUTENPRINT_ARRAY_H
  32. #define GUTENPRINT_ARRAY_H
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #include <gutenprint/sequence.h>
  39.  
  40.  
  41.   /**
  42.    * The array is a simple "two-dimensional array of numbers" data
  43.    * structure.  array "inherits" from the sequence data structure
  44.    * (implemented via containment).
  45.    *
  46.    * @defgroup array array
  47.    * @{
  48.    */
  49.  
  50. struct stp_array;
  51.   /** The array opaque data type. */
  52. typedef struct stp_array stp_array_t;
  53.  
  54.   /**
  55.    * Create a new array.
  56.    * The total size of the array will be (x_size * y_size).
  57.    * @param x_size the number of "columns".
  58.    * @param y_size the number of "rows".
  59.    * @returns the newly created array.
  60.    */
  61. extern stp_array_t *stp_array_create(int x_size, int y_size);
  62.  
  63.   /**
  64.    * Destroy an array.
  65.    * It is an error to destroy the array more than once.
  66.    * @param array the array to destroy.
  67.    */
  68. extern void stp_array_destroy(stp_array_t *array);
  69.  
  70.   /**
  71.    * Copy an array.
  72.    * Both dest and source must be valid arrays previously created with
  73.    * stp_array_create().
  74.    * @param dest the destination array.
  75.    * @param source the source array.
  76.    */
  77. extern void stp_array_copy(stp_array_t *dest, const stp_array_t *source);
  78.  
  79.   /**
  80.    * Copy and allocate an array.
  81.    * dest will be created, and then the contents of source will be
  82.    * copied into it.  dest must not have been previously allocated
  83.    * with stp_array_create().
  84.    * @param array the source array.
  85.    * @returns the new copy of the array.
  86.    */
  87. extern stp_array_t *stp_array_create_copy(const stp_array_t *array);
  88.  
  89.   /**
  90.    * Resize an array.
  91.    * Resizing an array will destroy all data stored in the array.
  92.    * @param array the array to resize.
  93.    * @param x_size the new number of "columns".
  94.    * @param y_size the new number of "rows".
  95.    */
  96. extern void stp_array_set_size(stp_array_t *array, int x_size, int y_size);
  97.  
  98.   /**
  99.    * Get the size of an array.
  100.    * The current x and y sizes are stored in the integers pointed to
  101.    * by x_size and y_size.
  102.    * @param array the array to get the size of.
  103.    * @param x_size a pointer to an integer to store the x size in.
  104.    * @param y_size a pointer to an integer to store the y size in.
  105.    */
  106. extern void stp_array_get_size(const stp_array_t *array, int *x_size, int *y_size);
  107.  
  108.   /**
  109.    * Set the data in an array.
  110.    * @param array the array to set.
  111.    * @param data a pointer to the first member of an array containing
  112.    * the data to set.  This array must be at least as long as (x_size
  113.    * * y_size).
  114.    */
  115. extern void stp_array_set_data(stp_array_t *array, const double *data);
  116.  
  117.   /**
  118.    * Get the data in an array.
  119.    * @param array the array to get the data from.
  120.    * @param size the number of elements in the array (x_size * y_size)
  121.    * are stored in the size_t pointed to.
  122.    * @param data a pointer to the first element of an array of doubles
  123.    * is stored in a pointer to double*.
  124.    * @code
  125.    * stp_array_t *array;
  126.    * size_t size;
  127.    * double *data;
  128.    * stp_array_get_data(array, &size, &data);
  129.    * @endcode
  130.    */
  131. extern void stp_array_get_data(const stp_array_t *array, size_t *size,
  132.                    const double **data);
  133.  
  134.   /**
  135.    * Set the data at a single point in the array.
  136.    * @param array the array to use.
  137.    * @param x the x location.
  138.    * @param y the y location.
  139.    * @param data the datum to set.
  140.    * @returns 1 on success, 0 on failure.
  141.    */
  142. extern int stp_array_set_point(stp_array_t *array, int x, int y,
  143.                    double data);
  144.  
  145.   /**
  146.    * Get the data at a single point in the array.
  147.    * @param array the array to use.
  148.    * @param x the x location.
  149.    * @param y the y location.
  150.    * @param data the datum is stored in the double pointed to.
  151.    * @returns 1 on success, 0 on failure.
  152.    */
  153. extern int stp_array_get_point(const stp_array_t *array, int x, int y,
  154.                    double *data);
  155.  
  156.   /**
  157.    * Get the underlying stp_sequence_t.
  158.    * @param array the array to use.
  159.    * @returns the (constant) stp_sequence_t.
  160.    */
  161. extern const stp_sequence_t *stp_array_get_sequence(const stp_array_t *array);
  162.  
  163.   /** @} */
  164.  
  165. #ifdef __cplusplus
  166.   }
  167. #endif
  168.  
  169. #endif /* GUTENPRINT_ARRAY_H */
  170.